﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Twitter;

namespace FriendsNearbyBot
{
    public class HiProcessor : IMessageProcessor
    {
        IMessageBuilder messageBuilder;

        public HiProcessor() : this(new PlainTextMessageBuilder())
        {
        }

        public HiProcessor(IMessageBuilder messageBuilder)
        {
            this.messageBuilder = messageBuilder;
        }

        #region IMessageProcessor Members
        
        public bool CanProcess(Message message)
        {
            return message.Text == "hi" || message.Text == "hello";
        }

        public RunNextProcessor Process(IBotClient client, Message message)
        {
            if (CanProcess(message))
            {
                // Send help to user SMS.
                messageBuilder.Clear();
                messageBuilder.AppendFragment(Properties.Resources.HiMessage);
                client.SendMessages(message.Sender.ScreenName, messageBuilder.GetMessages(), message, this.GetType().Name);

                BotProcessor.MessageProcessed(client, message);

                return RunNextProcessor.No;
            }
            else
                return RunNextProcessor.Yes;


        }

        #endregion
    }
}
